<template>
    <div class="xtx-goods-page">
        <div class="container">
            <!-- 面包屑 -->
            <div class="bread-container">
                <el-breadcrumb separator=">">
                    <el-breadcrumb-item :to="{ path: '/portal' }">首页</el-breadcrumb-item>
                    <el-breadcrumb-item>{{ goodInfo.name }}</el-breadcrumb-item>
                </el-breadcrumb>
            </div>
            <!-- 商品信息 -->
            <div class="info-container">
                <div>
                    <div class="goods-info">
                        <div class="media">
                        <!-- 图片预览区 -->
                          <img :src="goodInfo.image" />
                        <!-- 统计数量 -->
<!--                        <ul class="goods-sales">-->
<!--                            <li>-->
<!--                            <p>销量人气</p>-->
<!--                            <p> {{ goodInfo.salesCount }}+ </p>-->
<!--                            <p><i class="iconfont icon-task-filling"></i>销量人气</p>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                            <p>商品评价</p>-->
<!--                            <p>{{ goodInfo.commentCount }}+</p>-->
<!--                            <p><i class="iconfont icon-comment-filling"></i>查看评价</p>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                            <p>收藏人气</p>-->
<!--                            <p>{{ goodInfo.collectCount }}+</p>-->
<!--                            <p><i class="iconfont icon-favorite-filling"></i>收藏商品</p>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                            <p>品牌信息</p>-->
<!--                            <p>{{ goodInfo.brand?.name }}</p>-->
<!--                            <p><i class="iconfont icon-dynamic-filling"></i>品牌主页</p>-->
<!--                            </li>-->
<!--                        </ul>-->
                        </div>
                        <div class="spec">
                        <!-- 商品信息区 -->
                        <p class="g-name"> {{ goodInfo.name }}
<!--                          <el-tag class="ml-2" type="danger" v-if="goodInfo.isPrescription == 1">处方药</el-tag>-->
<!--                          <el-tag class="ml-2" type="success" v-else>非处方药</el-tag></p>-->
<!--                        <p class="g-desc">{{ goodInfo.content }} </p>-->
                        <p class="g-price">
                            <span>{{ goodInfo.price }}</span>
<!--                            <span>{{ 1000 }}</span>-->
                        </p>
                        <div class="g-service">
                            <dl>
                            <dt>描述</dt>
                            <dd>{{ goodInfo.content }}</dd>
                            </dl>
                            <dl>
                            <dt>店铺</dt>
                            <dd>{{ goodInfo.florist }}</dd>
                            </dl>
<!--                            <dl>-->
<!--                            <dt>类型</dt>-->
<!--                              <dd  v-if="goodInfo.isPrescription == 1">处方药</dd>-->
<!--                              <dd  v-else>非处方药</dd>-->
<!--                            </dl>-->
<!--                            <dl>-->
                            <dt>服务：</dt>
                            <dd>
                                <span>优质花材 品质保障</span><br>
                                <span>原创花艺 特色服务</span><br>
                                <span>急速配送 送货上门</span>
                            </dd>
                            </dl>
                        </div>
                        <!-- 数据组件 -->
                          <br>
                        <el-input-number v-model="count" @change="countChange"  label="数量" :min="1"></el-input-number>

                        <!-- 按钮组件 -->
                        <div>
                            <el-button size="large" class="btn" @click="addCart">
                            加入购物车
                            </el-button>
                        </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import { mapState } from 'vuex';
export default {
    name:'Detail',
    data(){
        return{
            count:1,
            skuObj:{},
        }
    },
    mounted(){
        this.$store.dispatch('detail/getDetailData',this.$route.params.id);
    },
    computed:{
        ...mapState('detail',['goodInfo']),
    },
    methods:{
        skuChange(sku){
            console.log(sku)
            this.skuObj = sku;
        },
        countChange(){
            console.log(this.count)
        },
        // 添加购物车
        addCart(){
            // if(this.skuObj.skuId){
                // 规格已经选择 触发action
                this.$store.dispatch('cartstore/addCart', {
                    id:this.goodInfo.id,
                    price:this.goodInfo.price,
                    count:this.count,
                    selected:true,
                })
                this.$message.success('成功加入'+this.count+'件到购物车');
        }
    }
}
</script>

<style scoped lang='scss'>
.xtx-goods-page {
    .goods-info {
        min-height: 600px;
        background: #FCFAF7;
        display: flex;

        .media {
        width: 580px;
        height: 600px;
        padding: 30px 50px;
        }

        .spec {
        flex: 1;
        padding: 30px 30px 30px 0;
        }
    }

    .goods-footer {
        display: flex;
        margin-top: 20px;

        .goods-article {
        width: 940px;
        margin-right: 20px;
        }

        .goods-aside {
        width: 280px;
        min-height: 1000px;
        }
    }

    .goods-tabs {
        min-height: 600px;
        background: #FCFAF7;
    }

    .goods-warn {
        min-height: 600px;
        background: #FCFAF7;
        margin-top: 20px;
    }

    .number-box {
        display: flex;
        align-items: center;

        .label {
        width: 60px;
        color: #999;
        padding-left: 10px;
        }
    }

    .g-name {
        font-size: 22px;
    }

    .g-desc {
        color: #999;
        margin-top: 10px;
    }

    .g-price {
        margin-top: 10px;

        span {
        &::before {
            content: "¥";
            font-size: 14px;
        }

        &:first-child {
            color: $priceColor;
            margin-right: 10px;
            font-size: 22px;
        }

        //&:last-child {
        //    color: #999;
        //    text-decoration: line-through;
        //    font-size: 16px;
        //}
        }
    }

    .g-service {
        background: #f5f5f5;
        width: 500px;
        padding: 20px 10px 0 10px;
        margin-top: 10px;

        dl {
        padding-bottom: 20px;
        display: flex;
        align-items: center;

        dt {
            width: 50px;
            color: #999;
        }

        dd {
            color: #666;

            &:last-child {
            span {
                margin-right: 10px;

                &::before {
                content: "•";
                color: $xtxColor;
                margin-right: 2px;
                }
            }

            a {
                color: $xtxColor;
            }
            }
        }
        }
    }

    .goods-sales {
        display: flex;
        width: 400px;
        align-items: center;
        text-align: center;
        height: 140px;

        li {
        flex: 1;
        position: relative;

        ~li::after {
            position: absolute;
            top: 10px;
            left: 0;
            height: 60px;
            border-left: 1px solid #e4e4e4;
            content: "";
        }

        p {
            &:first-child {
            color: #999;
            }

            &:nth-child(2) {
            color: $priceColor;
            margin-top: 10px;
            }

            &:last-child {
            color: #666;
            margin-top: 10px;

            i {
                color: $xtxColor;
                font-size: 14px;
                margin-right: 2px;
            }

            &:hover {
                color: $xtxColor;
                cursor: pointer;
            }
            }
        }
        }
    }
    }

    .goods-tabs {
    min-height: 600px;
    background: #FCFAF7;

    nav {
        height: 70px;
        line-height: 70px;
        display: flex;
        border-bottom: 1px solid #f5f5f5;

        a {
        padding: 0 40px;
        font-size: 18px;
        position: relative;

        >span {
            color: $priceColor;
            font-size: 16px;
            margin-left: 10px;
        }
        }
    }
    }

    .goods-detail {
    padding: 40px;

    .attrs {
        display: flex;
        flex-wrap: wrap;
        margin-bottom: 30px;

        li {
        display: flex;
        margin-bottom: 10px;
        width: 50%;

        .dt {
            width: 100px;
            color: #999;
        }

        .dd {
            flex: 1;
            color: #666;
        }
        }
    }

    >img {
        width: 100%;
    }
    }

    .btn {
    margin-top: 20px;

    }

    .bread-container {
    padding: 25px 0;
    }
</style>
